<template>
    <div class="app-container">
     
      <div class="listBox">
        <!-- <div class="listBox_head">
          <el-button type="primary" style="margin: 10px 0 20px" @click="addClick">新增行业</el-button>
        </div> -->
        <el-table v-loading="loading" :data="tabList" stripe border>
          <el-table-column label="序号" align="center" type="index" width="64px" />
          <el-table-column label="名称" align="center" prop="shortName" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column label="市县简介" align="center" prop="introduce" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column label="创建时间" align="center" prop="createTime" :show-overflow-tooltip="true"></el-table-column>
          <el-table-column label="最新更新时间" align="center" prop="updateTime" :show-overflow-tooltip="true"></el-table-column>
         
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button size="mini" type="text" @click="editClick(scope.row)">编辑</el-button>
            </template>
          </el-table-column>
        </el-table>
  
        <!-- <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" -->
          <!-- @pagination="getList"></pagination> -->
      </div>
      <Dialog :id="dialogId" v-bind="$attrs" v-if="dialogVisible" :visible.sync="dialogVisible" @success="_handleSuccess">
      </Dialog>
    </div>
  </template>
  
  <script>
    import {
      areaList,
      getAreaDetails,
    } from "@/api/setting/city";
    import Dialog from "@/views/setting/hainanCityManagement/components/dialog";
    export default {
      name: "",
      components: {
        Dialog
      },
      data() {
        return {
          dialogId: '',
          dialogVisible: false,
          // 遮罩层
          loading: false,
          // 导出遮罩层
          // 总条数
          total: 0,
          //表格数据
          tabList: [],
          city:'',
        };
      },
      created() {
        this.getList();
      },
      methods: {
        /** 查询列表 */
        getList() {
          this.loading = true;
          areaList().then(response => {
            response.result.forEach(item => {
                    for (var key in item) {
                        if (item[key] === '') {
                            item[key] = "-";
                        }
                    }
                });
            this.tabList = response.result;
            this.total = response.result.size;
            console.log(this.total)
            this.loading = false;
          });
        },
        getAreaDetails(){
          this.loading = true;
          getAreaDetails(this.city).then(response => {
            // this.tabList = response.result;
            // this.total = response.result.size;
            console.log(response.result)
          
            this.loading = false;
          });
        },
        // 编辑
        editClick(row) {
          this.dialogId = row.id
          this.dialogVisible = true;
        },
        _handleSuccess(e) {
          //成功回调
          // this.resetQuery()
          this.getList()
        },
      }
    };
  
  </script>
  <style scoped>
  
    .listBox {
      box-shadow: 0px 4px 12px 0px rgb(1 41 99 / 6%);
      background-color: #fff;
      border-radius: 8px;
      padding: 20px 20px;
      margin-top: 10px;
    }
  
  
  </style>
  